<?php
/**
 *
 */
class M_updateUtil extends CI_Model {

  public function __construct() {
    parent::__construct();
    $this->load->database();
  }
  public function update_shopinfo($shopid,$cloum,$data){
    if(!$shopid || !$cloum || !$data)return false;
    $sql = ' update shop set '.$cloum.'='.$data.' where shopid='.$shopid;
    return $this->db->query($sql);
  }
  public function update_employee($empid,$cloum,$data){
    if(!$empid || !$cloum || !$data)return false;
    $sql = ' update employee set '.$cloum.'='.$data.' where empid='.$empid;
    return $this->db->query($sql);
  }
  public function updatepwd($uid,$opwd,$npwd){
    if($uid=='admin'){
      if($this->db->query('select * from users where username="'.$uid.'" and password="'.$opwd.'"')->num_rows()>0){
        $sql = 'update users set password ="'.$npwd.'" where username="'.$uid.'" and password="'.$opwd.'"';
        return $this->db->simple_query($sql);
      }else{
        return 'false';
      }
    }else{
      if($this->db->query('select * from employees where emid="'.$uid.'" and password="'.$opwd.'"')->num_rows()>0){
        $sql = 'update employees set password ="'.$npwd.'" where emid="'.$uid.'" and password="'.$opwd.'"';
        return $this->db->simple_query($sql);
      }else{
        return 'false';
      }
      // $sql = 'update users set password ='.$npwd.' where emid="'.$uid.'" and password="'.$opwd.'"';
    }
    // return $sql;
    // return $sql;
  }
}
